home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctjja86.arc
/
STATEC.ARC
/
SIEVE.C
< prev
Wrap
Text File
|
1985-08-19
|
774b
|
44 lines
/* sieve.c - sieve benchmark program */
#define true 1
#define false 0
#define ssize 8190
#define sizepl 8191
#include "stdio.h"
main()
{
int i , niter , count ;
printf("\n no. iterations:\n");
scanf("%d",&niter);
for( i=1 ; i <= niter ; i=i+1 )
{ count = sieve() ; } ;
printf("\n thru - %d primes \n",count);
}
int sieve()
{
int i,prime,k,count;
char flags[sizepl];
count=0;
for(i = 0; i<=ssize;i++)
flags[i]=true;
for(i=0;i <= ssize; i++){
if(flags[i]){
prime = i+i+3;
k=i+prime;
while(k<=ssize){
flags[k] = false;
k += prime;
}
count = count+1;
}
}
return(count);
}